<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <h1>{{name}}</h1>
        <h2>{{revName}}</h2>
        <h3>这个是的全名是:{{fullName}}</h3>
        <input type="text" v-model='firstName'>
        <input type="text" v-model='lastName'>
    </div>
</body>
</html>
<script src="../node_modules/vue/dist/vue.js"></script>
<script>
    let vm = new Vue({
        el:'#app',
        data:{
            name:"珠峰",
            revName:'',
            firstName:'',
            lastName:'',
            fullName:''
        },
        // computed:{
        //   fullName(){
        //     return this.firstName + '-' + this.lastName
        //   }
        // },
        watch: {
          // 监听 这里都是已经存在的属性
          name(newV,oldV){
            // 只要那么 发生改变 这个函数就会执行
            // 这里边编写同异步都可以
            console.log(arguments)
            console.log(this.name)
            this.revName = newV.split('').reverse().join('')
            // return 666
          },
          firstName(val){
            setTimeout(() => {
              this.fullName = val + '-' + this.lastName
            }, 1000);
          },
          lastName(val){
            setTimeout(() => {
              this.fullName = this.firstName + '-' + val
            }, 1000);
          }
        },
    });
</script>